<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>标题</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<table class="layui-hide" id="dataList" lay-filter="dataList"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="passBtn">审核通过</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="noPassBtn">审核不通过</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看</a>
</script>

<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<script>
    layui.use(['jquery', 'configureCom', 'configure', 'table', 'sessionFun'], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var matchDict = layui.matchDict;
        var table = layui.table;
        var sessionFun = layui.sessionFun;
        var configureCom = layui.configureCom;

        var cols = [[
            {type: 'checkbox'},
            {
                field: 'registerType', title: '证书类别', templet: function (d) {
                    return '<p>' + d.registerType + '</p><p>专业:' + (d.aptitudeSpeciality || '-') + '</p>';
                }
            },
            {
                field: 'aptitudeNumber', title: '证书编号', templet: function (d) {
                    return '<p>' + d.aptitudeNumber + '</p><p>批准文号:' + d.authorizeNo + '</p>';
                }
            },
            {field: 'expiryTime', title: '证书有效期至'},
            {
                field: 'aptitudeOrg', title: '发证机关', templet: function (d) {
                    return '<p>' + d.aptitudeOrg + '</p><p>发证日期:' + (d.grantTime || '-') + '</p>';
                }
            },
            {field: 'aptitudeStatusName', title: '状态'},
            {title: '操作', toolbar: '#barDemo', width: 220}
        ]];
        configureCom.tableRender(configure.ORG_ZIZHI_CERT_LIST, {aptitudeStatus: 1}, cols, 'dataList', 10, 'full-50', 'toolbarOrg');

        //每行操作
        table.on('tool(dataList)', function (obj) {
            var data = obj.data;
            if (obj.event === 'passBtn') {//查看详情
                changePass(data.id, configure.ORG_ZIZHI_CERT_PASS_HTTP);
            } else if (obj.event === 'noPassBtn') {
                changePass(data.id, configure.ORG_ZIZHI_CERT_NOPASS_HTTP);
            }
        });

        function changePass(orgNo, url) {
            configureCom.postDataAjax(url, {userAptitudeId: orgNo}).then(function (res) {
                if (res.code == 0) {
                    top.layer.msg('设置成功！');
                    configureCom.tableReload(true);
                } else {
                    top.layer.alert('设置失败！')
                }
            });
        }
    });

</script>
</body>
</html>